Skip to main content

All Questions

2votes
1answer
846views

Better way to implement a feature with turn on/off based on a flag

I'm trying to implement a feature with option to turn it on/off based on a flag. I'm doing it in the following way which I feel like a overkill, public interface Feature { public interface ...
Tom Taylor's user avatar
0votes
4answers
2kviews

Can factory pattern avoid code smell?

With two existing implementations, UFOEnemyShip & RocketEnemyShip, To introduce every new implementation implementing EnemyShip interface, shown below, changes are needed in factory class ...
user1787812's user avatar
4votes
1answer
227views

How to make sure that each field's setter executes a specific code?

I am working with Java 1.7, IDE is Eclipse Indigo. I have a base class which has id as an int. It also has a boolean variable onlyIdInitialized; I am setting it to true when an object is created with ...
srh's user avatar
  • 143
4votes
2answers
4kviews

Class becoming God Object what pattern to use

I am developing Android app and my MainActivity is becoming God Object. By the way native Activity class implementation is some sort of God Object already. The problem is that my activity class is ...
CROSP's user avatar
  • 1,558
2votes
3answers
307views

Which one of these designs is preferred? [duplicate]

In the case of an application with a single simple responsibility (eg, a simple replacement for grep or wc), which of these designs is preferred and why? I find that they are all testable and they all ...
stackular's user avatar
14votes
9answers
22kviews

Are too many if-else statements for validation bad? [duplicate]

From the book Professional Enterprise .Net, which has 5 star rating on Amazon that I am doubting after having a read through. Here is a Borrower class (In C# but it's pretty basic; anyone can ...
iAteABug_And_iLiked_it's user avatar
14votes
5answers
2kviews

Is this pattern bad? [duplicate]

I notice that when I code I often use a pattern that calls a class method and that method will call a number of private functions in the same class to do the work. The private functions do one thing ...
user86834's user avatar
3votes
1answer
383views

Distinguishing repetitive code with the same implementation

Given this sample code import java.util.ArrayList; import blackjack.model.items.Card; public class BlackJackPlayer extends Player { private double bet; private Hand hand01 = new Hand(); ...
KyelJmD's user avatar

close